<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page isELIgnored="false" %>
<%@ page import="org.game.porker.porker24.util.ConstantUtil" %>
<%@ taglib  uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<html>
<title>主页</title>
<body>
<h2>排行榜</h2>
<% int i = 1; %>
<table>
<tr><th>排名</th><th>玩家</th><th>平均分数</th></tr>
<c:forEach items="${top10}" var="player">
<tr><td><%=i %></td><td>${player.loginName}</td>
<td>${player.avgScore}</td></tr>
<% i++; %>
</c:forEach>
</table>
<br>
<% if (session.getAttribute(ConstantUtil.playerInSessionKey) == null) {%>
<a href="<%=request.getContextPath() %>/player/login">登录</a>
<a href="<%=request.getContextPath() %>/player/register">注册</a>
<% } else { %>
<a href="<%=request.getContextPath() %>/player/logout">退出</a>
<a href="<%=request.getContextPath() %>/game/start">来一局</a>
<% } %>
</body>
</html>
